package uplift.project;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

public class RatingActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rating);
        
        ActionBar actionBar = getActionBar();
	    actionBar.setDisplayHomeAsUpEnabled(true);
    }
    
    // handles action item button presses
  	@Override
  	public boolean onOptionsItemSelected(MenuItem item) {
  		if(item.getItemId() == android.R.id.home) {
  			// move up the hierarchy

  			Intent i = new Intent(getApplicationContext(), SuggestionListActivity.class);
  			i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  			startActivity(i);
  		} else if(item.getItemId() == R.id.menu_home) {
  			// go to Home screen
  			
  			Intent i = new Intent(getApplicationContext(), UpliftActivity.class);
  			i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  			startActivity(i);
  		} else if(item.getItemId() == R.id.menu_my_events) {
  			// go to My Events screen
  			
  			Intent i = new Intent(getApplicationContext(), MyEventsTabActivity.class);
  			i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  			startActivity(i);
  		}
  		return true;
  	}
  	
  	// set up Action Bar
  	@Override
  	public boolean onCreateOptionsMenu(Menu menu) {
  	    MenuInflater inflater = getMenuInflater();
  	    inflater.inflate(R.menu.action_bar, menu);
  	    return true;
  	}
 	
    
    // called when the submit button is clicked
    // goes back to home screen
    public void submitRating(View v) {
    	Toast.makeText(this.getApplicationContext(), "Thanks for rating!", Toast.LENGTH_SHORT).show();
    	Intent i = new Intent(v.getContext(), UpliftActivity.class);
    	i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    	startActivity(i);
    }
}
